package com.noname.lib_base_java.global;

import android.content.Context;
import android.os.Handler;
import android.os.StrictMode;
import android.support.multidex.MultiDexApplication;

import com.noname.lib_base_java.net.NetManager;
import com.noname.lib_base_java.util.SharedPrefUtil;

/**
 * Author: Lmoumou
 * Date: 2018-12-10 11:24
 * 文件名: GlobalApplication
 * 描述:
 */
public class GlobalApplication extends MultiDexApplication {
    protected static Context context;
    protected static Handler handler;
    protected static int mainThreadId;

    @Override
    public void onCreate() {
        super.onCreate();
        context = getApplicationContext();
        handler = new Handler();
        mainThreadId = android.os.Process.myTid();



        //兼容7.0访问本地资源
        StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
        StrictMode.setVmPolicy(builder.build());
        builder.detectFileUriExposure();

//        PreferencesUtil.Companion.get(this);
        SharedPrefUtil.init(this);
    }

    /**
     * 获取上下文对象
     *
     * @return context
     */
    public static Context getContext() {
        return context;
    }

    /**
     * 获取全局handler
     *
     * @return 全局handler
     */
    public static Handler getHandler() {
        return handler;
    }

    /**
     * 获取主线程id
     *
     * @return 主线程id
     */
    public static int getMainThreadId() {
        return mainThreadId;
    }

}
